package com.df.managers.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;

import com.df.managers.AbstractManager;
import com.df.managers.TypeManager;
import com.df.news.News;
import com.df.page.PagerModel;
import com.df.type.Type;
@Service("typeManager")
public class TypeManagerImpl extends AbstractManager implements TypeManager {

	@Resource
	public void setSessionF(SessionFactory sessionFactory){
    	super.setSessionFactory(sessionFactory);
    }
	public void add(Type t) {
	 getHibernateTemplate().saveOrUpdate(t);
	}

	public List  list() {
        
		return getHibernateTemplate().find("from Type");
	}
	public void del(int id) {
		getHibernateTemplate().delete(getHibernateTemplate().get(Type.class, id));
		
	}
	public Type getById(int id) {
		
		return getHibernateTemplate().get(Type.class, id);
	}
	public Type getById(String showName) {
		Query query = this.getSession().createQuery("from Type n where n.showName = '"+showName+"'");
		return (Type) query.uniqueResult();
	}

}
